from processing.model.component import Component
from pyprocessing import line, stroke, strokeWeight
from processing.shape.color import color

class Conection(Component):
    
    def __init__(self, start, end, line_color=None):
        Component.__init__(self)
        self.__color = line_color or color.orange
        self.__start = start
        self.__end = end
        self.__life = 5

    def update(self):
        self.life -= 1
        if(self.life < 1):
            self.destroy()
        
    def draw(self):
        stroke(*self.color)
        strokeWeight(self.life + 1)
        line(self.start.gx + 6, self.start.gy + 6, self.end.gx + 6, self.end.gy + 6)
        strokeWeight(1)
         
    @property
    def start(self):
        return self.__start
    
    @property
    def end(self):
        return self.__end
    
    @property
    def color(self):
        return self.__color
    
    @property
    def life(self):
        return self.__life
    
    @life.setter
    def life(self, value):
        self.__life = value
        
        